<?php

require_once(sfConfig::get('sf_lib_dir').'/filter/base/BaseFormFilterPropel.class.php');

/**
 * Student filter form base class.
 *
 * @package    elearning
 * @subpackage filter
 * @author     Your name here
 */
class BaseStudentFormFilter extends BaseFormFilterPropel
{
  public function setup()
  {
    $this->setWidgets(array(
      'country_id'       => new sfWidgetFormPropelChoice(array('model' => 'Country', 'add_empty' => true)),
      'language_id'      => new sfWidgetFormPropelChoice(array('model' => 'Language', 'add_empty' => true)),
      'std_account_name' => new sfWidgetFormFilterInput(),
      'std_first_name'   => new sfWidgetFormFilterInput(),
      'std_last_name'    => new sfWidgetFormFilterInput(),
      'birthday'         => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => true)),
      'std_phone'        => new sfWidgetFormFilterInput(),
      'std_email'        => new sfWidgetFormFilterInput(),
      'std_avatar_image' => new sfWidgetFormFilterInput(),
      'std_password'     => new sfWidgetFormFilterInput(),
      'std_status'       => new sfWidgetFormFilterInput(),
      'std_last_vistit'  => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'std_credit'       => new sfWidgetFormFilterInput(),
      'created_at'       => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => true)),
      'updated_at'       => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => true)),
    ));

    $this->setValidators(array(
      'country_id'       => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Country', 'column' => 'iso')),
      'language_id'      => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Language', 'column' => 'id')),
      'std_account_name' => new sfValidatorPass(array('required' => false)),
      'std_first_name'   => new sfValidatorPass(array('required' => false)),
      'std_last_name'    => new sfValidatorPass(array('required' => false)),
      'birthday'         => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'std_phone'        => new sfValidatorPass(array('required' => false)),
      'std_email'        => new sfValidatorPass(array('required' => false)),
      'std_avatar_image' => new sfValidatorPass(array('required' => false)),
      'std_password'     => new sfValidatorPass(array('required' => false)),
      'std_status'       => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'std_last_vistit'  => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'std_credit'       => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'created_at'       => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'updated_at'       => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
    ));

    $this->widgetSchema->setNameFormat('student_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'Student';
  }

  public function getFields()
  {
    return array(
      'id'               => 'Number',
      'country_id'       => 'ForeignKey',
      'language_id'      => 'ForeignKey',
      'std_account_name' => 'Text',
      'std_first_name'   => 'Text',
      'std_last_name'    => 'Text',
      'birthday'         => 'Date',
      'std_phone'        => 'Text',
      'std_email'        => 'Text',
      'std_avatar_image' => 'Text',
      'std_password'     => 'Text',
      'std_status'       => 'Number',
      'std_last_vistit'  => 'Date',
      'std_credit'       => 'Number',
      'created_at'       => 'Date',
      'updated_at'       => 'Date',
    );
  }
}
